package com.app.pojo;

import java.util.Date;

public class Share {

    /**
     * 第一个open为共享开关，第二个为搜索开关
     */
    public static final String shareOpenOpen="share-11.dat";
    public static final String shareOpenClose="share-10.dat";
    public static final String shareCloseOpen="share-01.dat";
    public static final String shareCloseClose="share-00.dat";
    public String userId,path,permissions,password;
    public long timeout,creatTime;

    public String getUserId() {
        return userId;
    }

    public String getPath() {
        return path;
    }

    public String getPermissions() {
        return permissions;
    }

    public String getPassword() {
        return password;
    }

    public long getTimeout() {
        return timeout;
    }

    public long getCreatTime() {
        return creatTime;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public void setPermissions(String permissions) {
        this.permissions = permissions;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void setTimeout(long timeout) {
        this.timeout = timeout;
    }

    public void setCreatTime(long creatTime) {
        this.creatTime = creatTime;
    }

    public Share(String userId, String path, String permissions, String password, long timeout, long creatTime) {
        this.userId = userId;
        this.path = path;
        this.permissions = permissions;
        this.password = password;
        this.timeout = timeout;
        this.creatTime = creatTime;
    }

    public Share(String userId, String path, String permissions, String password, long timeout) {
        this.userId = userId;
        this.path = path;
        this.permissions = permissions;
        this.password = password;
        this.timeout = timeout;
        creatTime=new Date().getTime();
    }

    public Share(String path, String permissions, String password, long timeout) {
        this.path = path;
        this.permissions = permissions;
        this.password = password;
        this.timeout = timeout;
        creatTime=new Date().getTime();
    }

    public Share(String line) {
        String[] sp=line.split(" ");
        path=sp[0];
        permissions=sp[1];
        password=sp[2];
        creatTime=Long.parseLong(sp[3]);
        timeout=Long.parseLong(sp[4]);
    }
    public boolean isOutOfTime(){
        return timeout>new Date().getTime();
    }
    @Override
    public String toString() {
        return path+" "+permissions+" "+password+" "+new Date().getTime()+" "+timeout;
    }
}
